﻿using DocumentFormat.OpenXml.Lite.Core.Office;
using DocumentFormat.OpenXml.Lite.WordprocessingML.Word.Base;
using DocumentFormat.OpenXml.Lite.WordprocessingML.Word.RunElements;
using DocumentFormat.OpenXml.Lite.WordprocessingML.Word.SectionProperties;
using DocumentFormat.OpenXml.Lite.WordprocessingML.Word.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Samples.Word
{
    class Orientations
    {
        public static void Create()
        {
            Document doc = DocumentManager.Instance.CreateWordDocument();
            doc.CreateBody().AddParagraph().AddRun().AddSimpleText("This is a landscape page");

            Paragraph p = doc.Body.AddParagraph();
            p.AddSectionProperty(new PageSize()
            {
                Width = 16838,
                Height = 11906,
                Orientation = ST_PageOrientation.Landscape
            });

            doc.Body.AddParagraph().AddRun().AddElement(new LastCalculatedPageBreak());

            doc.Body.AddParagraph().AddRun().AddSimpleText("This is a portrait page");

            doc.Save(@"samples\orientation.docx");

            Document parsed = null;
            if (DocumentManager.Instance.OpenWordDocument(@"samples\orientation.docx", out parsed))
            {
                Console.WriteLine("Sample created and parsed succesfully!");
            }
            Console.ReadLine();
        }
    }
}
